package com.ckjava.test.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Map;

/**
 * 分页参数对象
 */
@ApiModel("分页参数对象")
public class PageParamer {

    @ApiModelProperty("排序对象")
    private Sort sort;

    @ApiModelProperty("字段搜索对象")
    private Search search;

    @ApiModelProperty("分页导航条对象")
    private Pagination pagination;

    public Sort getSort() {
        return sort;
    }

    public void setSort(Sort sort) {
        this.sort = sort;
    }

    public Search getSearch() {
        return search;
    }

    public void setSearch(Search search) {
        this.search = search;
    }

    public Pagination getPagination() {
        return pagination;
    }

    public void setPagination(Pagination pagination) {
        this.pagination = pagination;
    }

    /**
     * 排序对象
     */
    @ApiModel("排序对象")
    public class Sort {
        @ApiModelProperty("排序字段")
        private String predicate;

        @ApiModelProperty("是否倒序")
        private boolean reverse;

        public String getPredicate() {
            return predicate;
        }

        public void setPredicate(String predicate) {
            this.predicate = predicate;
        }

        public boolean isReverse() {
            return reverse;
        }

        public void setReverse(boolean reverse) {
            this.reverse = reverse;
        }

        public Sort() {
        }

        public Sort(String predicate, boolean reverse) {
            this.predicate = predicate;
            this.reverse = reverse;
        }
    }

    /**
     * 字段搜索对象
     */
    @ApiModel("字段搜索对象")
    public class Search {

        @ApiModelProperty("关键字段")
        private Map<String, String> predicateObject;

        public Map<String, String> getPredicateObject() {
            return predicateObject;
        }

        public void setPredicateObject(Map<String, String> predicateObject) {
            this.predicateObject = predicateObject;
        }

        public Search() {
        }

        public Search(Map<String, String> predicateObject) {
            this.predicateObject = predicateObject;
        }
    }

    /**
     * 分页导航条对象
     */
    @ApiModel("分页导航条对象")
    public class Pagination {

        @ApiModelProperty("起始行")
        private Integer start;

        @ApiModelProperty("总记录数")
        private Integer totalItemCount;

        @ApiModelProperty("每页记录数")
        private Integer number;

        @ApiModelProperty("总页数")
        private Integer numberOfPages;

        public Integer getStart() {
            return start;
        }

        public void setStart(Integer start) {
            this.start = start;
        }

        public Integer getTotalItemCount() {
            return totalItemCount;
        }

        public void setTotalItemCount(Integer totalItemCount) {
            this.totalItemCount = totalItemCount;
        }

        public Integer getNumber() {
            return number;
        }

        public void setNumber(Integer number) {
            this.number = number;
        }

        public Integer getNumberOfPages() {
            return numberOfPages;
        }

        public void setNumberOfPages(Integer numberOfPages) {
            this.numberOfPages = numberOfPages;
        }

        public Pagination() {
        }

        public Pagination(Integer start, Integer totalItemCount, Integer number, Integer numberOfPages) {
            this.start = start;
            this.totalItemCount = totalItemCount;
            this.number = number;
            this.numberOfPages = numberOfPages;
        }
    }

    public PageParamer() {
    }

    public PageParamer(Sort sort, Search search, Pagination pagination) {
        this.sort = sort;
        this.search = search;
        this.pagination = pagination;
    }
}
